public class Test {
    public static int missingNumber(int[] nums) {
        int n = nums.length;
        int ret = 0;
        for (int i = 0; i <= n; i++) {
            ret ^= i;
        }
        for (int i = 0; i < n; i++) {
            ret ^= nums[i];
        }
        return ret;
    }

    public static void main(String[] args) {
        int[] nums = {1,2,3,0,5};
        int ret = missingNumber(nums);
        System.out.println(ret);
    }
}
